<?php
// 本类由系统自动生成，仅供测试用途
namespace MyClass;
class News extends \MyClass\Common {
    public function Lists(){
		
		/*if($_REQUEST['cate']){
			$catesql = "cate=".$_REQUEST['cate'];
			$this->s("cate",$_REQUEST['cate']);
		}*/
		//新闻分类
		//$newcate = $this->m("sys_news_cate")->field("*")->select();
		//新闻列表
		//$count = count($this->m("sys_news")->field("*")->where($catesql)->select());
		//$p = new \Extend\Page($count,10);
		$newslist = $this->m("sys_news")->field("*")->where($catesql)->order("creattime desc")->limit("6")->select();
	
		
		//$this->s('page',$p->show());
		//$this->s("newcate",$newcate);
		$this->s("newslist",$newslist);
		$this->v();
    }
   
	

	public function NewsContent(){
		if($_REQUEST['id']){
			//新闻内容
			$content = $this->m("sys_news")->field("*")->where("id=".$_REQUEST['id'])->find();
			
			//上一篇
			$prev = $this->m("sys_news")->field("*")->where("id<".$_REQUEST['id'])->order("id desc")->limit("0,1")->select();
			
			//下一篇	
			$next = $this->m("sys_news")->field("*")->where("id>".$_REQUEST['id'])->order("id asc")->limit("0,1")->select();
			
			$this->s("content",$content);
			$this->s("prev",$prev);
			$this->s("next",$next);
		}else{
			echo "不存在此新闻";
		}
		
		//推荐企业
		$tjqy = $this->m("sys_news")->limit("10")->select();
		$this->s('tjqy',$tjqy);
		$this->v();
	}






	public function PageAjax(){
		if(!isset($_REQUEST['page'])){
				$this->error("非法操作");
		}
		$thispage = (int)$_REQUEST['page']*6;
		$count = count($this->m("sys_news")->field("*")->where($catesql)->select());
		$list= $this->m("sys_news")->field("*")->where($catesql)->order("creattime desc")->limit($thispage.", 6")->select();
		$ifhy = ceil($count/6);
		if((int)$_REQUEST['page']>$ifhy){
			$list['ifhy'] = 1;
		}
		echo json_encode($list);
	
	}
	



	
}